How to Dynamically Recalculate a Page Layout, Tabbed UI or UX Component at Run-time

Description

If overrides have been defined for a Page Layout, Tabbed UI, or UX Component using the 'override_settings' property on the page the component is embedded, the component needs to recalculate the affected controls.

Discussion

Normally, if you set a control property in 'override settings' at run-time, it has no effect because the 'functionality' of the component is computed at design time from the control properties.

For example, say you set a button text at design time to be 'Run Report' and then at run time you override the 'buttonText' property to be 'Run Sales Report'. This will have no effect on the component because this property value was 'consumed' at design time to compute the actual HTML template.

Therefore, you must force the component to recalculate itself at run-time by setting the tmpl.flagForeRecalc flag to .t.

You can limit the number of controls to recalculate by setting an optional tmpl.controlsToRecalculate property. This property should be set to a crlf delimited string containing the 'idInternal' property of each control you want to recalculate.

For example, the page to run a Tabbed UI might have this code for the override settings:

tmpl.override_settings =<<%longString%
    tmpl.page_fields[1].v.buttonText = "New Button Label"
    tmpl.flagForceRecalc = .t.
    tmpl.controlsToRecalculate = "b779c6f0-011f-4254-9922-bf2f2727310b"
%longString%

If the tmpl.controlsToRecalculate property is not set, all controls in the component will be recalculated. In a large component this can cause a significant slowdown in the time taken to render the component.

See Also